package com.shqcjd.preinstallglass.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.preinstallglass.R;
import com.shqcjd.preinstallglass.model.pojo.EquipmentGroupBean;

import java.util.List;

public class InspectionStandardAdapter extends BaseQuickAdapter<EquipmentGroupBean.EquipmentStandardBean,BaseViewHolder> {
    private Context context;
    public InspectionStandardAdapter(@Nullable List<EquipmentGroupBean.EquipmentStandardBean> data, Context context) {
        super(R.layout.item_inspection_standard, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, EquipmentGroupBean.EquipmentStandardBean item) {
        LinearLayout ll_item_inspection_standard = helper.getView(R.id.ll_item_inspection_standard);
        TextView tv_item_inspection_standard = helper.getView(R.id.tv_item_inspection_standard);
        tv_item_inspection_standard.setText(item.equipment_type_name);

        for(int i=0; i<item.equipment_type_part.size(); i++){
            View vParent = LayoutInflater.from(context).inflate(R.layout.item_inspection_standard_item, null);
            LinearLayout ll_item_inspection_standard_parent = vParent.findViewById(R.id.ll_item_inspection_standard_parent);
            TextView tv_item_inspection_standard_item = vParent.findViewById(R.id.tv_item_inspection_standard_item);
            tv_item_inspection_standard_item.setText(item.equipment_type_part.get(i).equipment_type_part_name);
            for(int j=0; j<item.equipment_type_part.get(i).equipment_type_part_item.size(); j++){
                View vChild = LayoutInflater.from(context).inflate(R.layout.item_inspection_standard_item_child, null);
                ll_item_inspection_standard_parent.addView(vChild);
                TextView tv_item_inspection_standard_item_name = vChild.findViewById(R.id.tv_item_inspection_standard_item_name);
                tv_item_inspection_standard_item_name.setText(item.equipment_type_part.get(i).equipment_type_part_item.get(j).equipment_part_item_name);
                TextView tv_item_inspection_standard_item_state = vChild.findViewById(R.id.tv_item_inspection_standard_item_state);
                tv_item_inspection_standard_item_state.setText(item.equipment_type_part.get(i).equipment_type_part_item.get(j).standard);
            }
            ll_item_inspection_standard.addView(vParent);
        }
    }

}
